﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using BusinessLayer;
using System.Xml.Linq;
namespace PresentationLayer
{
    public partial class AdicioComun : Form
    {
        public AdicioComun()
        {
            InitializeComponent();
        }

        private void ficheiro_Click(object sender, EventArgs e)
        {
            EscolhaFicheiro.ShowDialog();
            this.textNomeFich.AppendText(this.EscolhaFicheiro.FileName);
        }

        private void Inserir_Click(object sender, EventArgs e)
        {
            String input = null;
            this.textNomeFich.SelectAll();
            this.textDep.SelectAll();
            this.textofic.SelectAll();
            XDocument file =  XDocument.Load(this.textNomeFich.SelectedText);
            
                input = file.ToString();
            

            if(ComunicadoActions.insereComunicado(input,this.textofic.SelectedText,this.textDep.SelectedText))
                this.Close();

            
        }
    }
}
